import java.util.Arrays;

public class MyStack {
    public int[] elem;

    public int usedSize;

    public MyStack(){
        this.elem=new int[10];
    }

    public void push(int val){
        if (isFull()){
            this.elem= Arrays.copyOf(elem,2*elem.length);
        }
        elem[usedSize++]=val;

    }

    public boolean isFull(){
        if (this.usedSize==this.elem.length)
            return true;
        return false;
    }

    public int pop(){
        if (isEmpty())
        return elem[--usedSize];
        return -1;
    }

    public int peek(){
        if (isEmpty()){
            return elem[usedSize-1];
        }
        return -1;
    }

    public boolean isEmpty()throws EmptyException{
        if (usedSize==0){
            throw new EmptyException("空位置异常！");
        }
        return true;
    }
}
